
package org.codebase.spring.framework.aop.annotation;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

/**
 * 切面环绕
 * *************************************************
 * ClassName:AudienceAround
 *

 * @author:xiaozhichao
 * @date:2018年9月3日 *************************************************
 */
@Aspect
@Component
public class AudienceAround {

    //切点表达式
    @Pointcut("execution(** org.codebase.spring.framework.aop.Performance.around(..))")
    public void around() {
    }

    @Around("around()")
    public void watchPerformance(ProceedingJoinPoint jp) {
        //测试jp方法
        MethodSignature methodSignature = (MethodSignature) jp.getSignature();
        String simpleName = methodSignature.getDeclaringType().getSimpleName();
        String name = methodSignature.getName();


        Object[] objs = jp.getArgs();
        for (Object obj : objs) {
            System.out.print(obj + ";");
        }
        System.out.println();
        try {
            System.out.println("watchPerformanceBefore");
            jp.proceed();
            System.out.println("watchPerformanceAfter");
        } catch (Throwable e) {


        }
    }


}
